/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */

/*
 *  Credenza
 *
 *  Copyright (C) 1999, 2000 Red Hat, Inc.
 *  Copyright (C) 1999, 2000, 2001 Eazel, Inc.
 *
 *  Credenza is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of the
 *  License, or (at your option) any later version.
 *
 *  Credenza is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *  Authors: Elliot Lee <sopwith@redhat.com>
 *           Darin Adler <darin@bentspoon.com>
 *
 */
/* credenza-window.h: Interface of the main window object */

#ifndef CREDENZA_WINDOW_H
#define CREDENZA_WINDOW_H

#include <gtk/gtk.h>
#include <eel/eel-glib-extensions.h>
#include <libcredenza-private/credenza-bookmark.h>
#include <libcredenza-private/credenza-window-info.h>
#include <libcredenza-private/credenza-search-directory.h>
#include "credenza-application.h"

#define CREDENZA_TYPE_WINDOW credenza_window_get_type()
#define CREDENZA_WINDOW(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CREDENZA_TYPE_WINDOW, CredenzaWindow))
#define CREDENZA_WINDOW_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), CREDENZA_TYPE_WINDOW, CredenzaWindowClass))
#define CREDENZA_IS_WINDOW(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CREDENZA_TYPE_WINDOW))
#define CREDENZA_IS_WINDOW_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), CREDENZA_TYPE_WINDOW))
#define CREDENZA_WINDOW_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), CREDENZA_TYPE_WINDOW, CredenzaWindowClass))

#ifndef CREDENZA_WINDOW_DEFINED
#define CREDENZA_WINDOW_DEFINED
typedef struct CredenzaWindow CredenzaWindow;
#endif

#ifndef CREDENZA_WINDOW_SLOT_DEFINED
#define CREDENZA_WINDOW_SLOT_DEFINED
typedef struct CredenzaWindowSlot CredenzaWindowSlot;
#endif

typedef struct _CredenzaWindowPane      CredenzaWindowPane;

typedef struct CredenzaWindowSlotClass CredenzaWindowSlotClass;
typedef enum CredenzaWindowOpenSlotFlags CredenzaWindowOpenSlotFlags;

GType          credenza_window_slot_get_type (void);

typedef enum {
        CREDENZA_WINDOW_NOT_SHOWN,
        CREDENZA_WINDOW_POSITION_SET,
        CREDENZA_WINDOW_SHOULD_SHOW
} CredenzaWindowShowState;

enum CredenzaWindowOpenSlotFlags {
	CREDENZA_WINDOW_OPEN_SLOT_NONE = 0,
	CREDENZA_WINDOW_OPEN_SLOT_APPEND = 1
};

typedef struct CredenzaWindowDetails CredenzaWindowDetails;

typedef struct {
        GtkWindowClass parent_spot;

        CredenzaWindowType window_type;
        const char *bookmarks_placeholder;

	/* Function pointers for overriding, without corresponding signals */

        char * (* get_title) (CredenzaWindow *window);
        void   (* sync_title) (CredenzaWindow *window,
			       CredenzaWindowSlot *slot);
        CredenzaIconInfo * (* get_icon) (CredenzaWindow *window,
					 CredenzaWindowSlot *slot);

        void   (* sync_allow_stop) (CredenzaWindow *window,
				    CredenzaWindowSlot *slot);
	void   (* set_allow_up) (CredenzaWindow *window, gboolean allow);
	void   (* reload)              (CredenzaWindow *window);
        void   (* prompt_for_location) (CredenzaWindow *window, const char *initial);
        void   (* get_min_size) (CredenzaWindow *window, guint *default_width, guint *default_height);
        void   (* get_default_size) (CredenzaWindow *window, guint *default_width, guint *default_height);
        void   (* close) (CredenzaWindow *window);

        CredenzaWindowSlot * (* open_slot) (CredenzaWindowPane *pane,
					    CredenzaWindowOpenSlotFlags flags);
        void                 (* close_slot) (CredenzaWindowPane *pane,
					     CredenzaWindowSlot *slot);
        void                 (* set_active_slot) (CredenzaWindowPane *pane,
						  CredenzaWindowSlot *slot);

        /* Signals used only for keybindings */
        gboolean (* go_up) (CredenzaWindow *window, gboolean close);
} CredenzaWindowClass;

struct CredenzaWindow {
        GtkWindow parent_object;
        
        CredenzaWindowDetails *details;
        
        /** CORBA-related elements **/
        CredenzaApplication *application;
};

GType            credenza_window_get_type             (void);
void             credenza_window_show_window          (CredenzaWindow    *window);
void             credenza_window_close                (CredenzaWindow    *window);

void             credenza_window_connect_content_view (CredenzaWindow    *window,
						       CredenzaView      *view);
void             credenza_window_disconnect_content_view (CredenzaWindow    *window,
							  CredenzaView      *view);

void             credenza_window_go_to                (CredenzaWindow    *window,
                                                       GFile             *location);
void             credenza_window_go_to_with_selection (CredenzaWindow    *window,
                                                       GFile             *location,
                                                       GList             *new_selection);
void             credenza_window_go_home              (CredenzaWindow    *window);
void             credenza_window_go_up                (CredenzaWindow    *window,
                                                       gboolean           close_behind,
						       gboolean           new_tab);
void             credenza_window_prompt_for_location  (CredenzaWindow    *window,
                                                       const char        *initial);
void             credenza_window_launch_cd_burner     (CredenzaWindow    *window);
void             credenza_window_display_error        (CredenzaWindow    *window,
                                                       const char        *error_msg);
void		 credenza_window_reload		      (CredenzaWindow	 *window);

void             credenza_window_allow_reload         (CredenzaWindow    *window,
                                                       gboolean           allow);
void             credenza_window_allow_up             (CredenzaWindow    *window, 
                                                       gboolean           allow);
void             credenza_window_allow_stop           (CredenzaWindow    *window, 
                                                       gboolean           allow);
void             credenza_window_allow_burn_cd        (CredenzaWindow    *window,
                                                       gboolean           allow);
void		 credenza_window_close_pane 		(CredenzaWindowPane *pane);

GtkUIManager *   credenza_window_get_ui_manager       (CredenzaWindow    *window);
gboolean         credenza_window_has_menubar_and_statusbar (CredenzaWindow *window);

#endif
